home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / applic1a / form.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-14  |  3.2 KB  |  71 lines

  1. VERSION 5.00
  2. Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Internet Update"
  6.    ClientHeight    =   930
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   2730
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   930
  14.    ScaleWidth      =   2730
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin InetCtlsObjects.Inet Inet1 
  17.       Left            =   0
  18.       Top             =   120
  19.       _ExtentX        =   1005
  20.       _ExtentY        =   1005
  21.       _Version        =   393216
  22.    End
  23.    Begin VB.CommandButton Command1 
  24.       Caption         =   "Check for update"
  25.       Height          =   465
  26.       Left            =   600
  27.       TabIndex        =   0
  28.       Top             =   240
  29.       Width           =   1455
  30.    End
  31. Attribute VB_Name = "Form1"
  32. Attribute VB_GlobalNameSpace = False
  33. Attribute VB_Creatable = False
  34. Attribute VB_PredeclaredId = True
  35. Attribute VB_Exposed = False
  36. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  37. Private Function HyperJump(ByVal URL As String) As Long
  38.     HyperJump = ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)
  39. End Function
  40. Private Sub Command1_Click()
  41. 'This function assume files "application.ver", "news.txt" and "application.zip"
  42. 'on server http://server.com/user (change "server.com/user" by your server name and path)
  43. 'Inspect contain of files "news.txt" and "application.ver" at examples
  44. Dim Version As String, News As String
  45.     On Error GoTo ErrorMessage
  46.     Me.MousePointer = 11
  47.     'now assign content of file application.ver to variable Version
  48.     Version = Inet1.OpenURL("http://server.com/user/application.ver")
  49.     'You can try this function on Your local disk, but You must change adresses:
  50.     'for example: "file://c:\path\application.ver"
  51.     If Version = "" Then GoTo Skip 'if file not found or file is empty then exit
  52.     If Version <= App.Major & "." & App.Minor Then
  53.         MsgBox "No newer version was released.", vbInformation
  54.         GoTo Skip
  55.     End If
  56.     'now display MessageBox with news in newer version(s) of application and two buttons Yes(update), No(end)
  57.     News = Inet1.OpenURL("http://server.com/user/news.txt")
  58.     If MsgBox(Mid(News, 1, InStr(1, News, App.Major & "." & App.Minor) - 9), vbYesNo, "You can update from version " & App.Major & "." & App.Minor & " to version " & Version) = vbYes Then
  59.         HyperJump "http://server.com/user/application.zip" 'this will run default download manager (probable also open default browser)
  60.     End If
  61. Skip:
  62.     Me.MousePointer = 0
  63.     Exit Sub
  64. ErrorMessage:
  65.     Me.MousePointer = 0
  66.     MsgBox "An error has occured. Update failed." & Chr(10) & "You must download new version of this application manually at http://server.com.", vbCritical
  67. End Sub
  68. Private Sub Form_Load()
  69.     Me.Caption = "Internet Update " & App.Major & "." & App.Minor
  70. End Sub
  71.